<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>补件记录列表</title>
    <jsp:include page="../../import.jsp" flush="true" />
    <script type="text/javascript">
        var grid = null;
        var _usrId = '${currentUsrId}';//当前用户ID
        var mgrPrjViewFlag = '${mgrPrjViewFlag}';//客户经理关联项目页面
        $(function () {
            var params = "";//默认条件
            var _cstMgrId = '${cstMgrId}';
            if(mgrPrjViewFlag == 'mgrPrjViewFlag' && StringUtils.isNotEmpty(_cstMgrId)){
                params ="?cstMgrId="+_cstMgrId;
            }
            initGrid(params);
            $("#searchBar").ligerForm();
            $("#searchBtn").click(function(event) {
                var form = new liger.get("searchBar");
                var data = form.getData();
                for (name in data){
                    grid.setParm(name,data[name]);
                };
                grid.reload();
            });
        });

        /**
         * 清空
         */
        function clearBtn(){
            $("#searchBar").ligerForm();
            var form = new liger.get("searchBar");
            form.setData({
                lsCntNo:" ",
                cstNm:" ",
                actPayTmBg:" ",
                actPayTmEd:" ",
                compltStsCd:" ",
                insCode:" ",
                compltNodeCd:" ",
                payStsCd:" "
            });
        }

        function initGrid(params){
        //初始化列表
            $("#grid").ligerGrid({
                url: '<%=path%>/insitution/prjInsRfeRecord/initList.do'+params,
                method : 'get',
                columns: [
                    { display: '合同号', name: 'lsCntNo', minWidth: 80 ,align:'left',enabledSort:true},
                    { display: '客户姓名', name: 'cstNm', minWidth: 60,align:'left',enabledSort:true},
                    { display: '第三方机构', name: 'fundRasInsNm', minWidth: 60,align:'left',enabledSort:true},
                    { display: '补件状态', name: 'compltStsCdNm', minWidth: 60,align:'left',enabledSort:true},
                    { display: '补件节点', name: 'compltNodeCdNm', minWidth: 60,align:'left',enabledSort:true},
                    { display: '资方放款时间', name: 'thdPayDt', minWidth: 60,align:'left', render:renderDate,enabledSort:true},
                    { display: '资方放款状态', name: 'payerStsCdNm', minWidth: 60,align:'left',enabledSort:true},
                    { display: '创建时间', name: 'crtTm', minWidth: 60,align:'left', render:renderDate,enabledSort:true},
                    { display: '流程编号', name: 'pNo', minWidth: 140 ,
                        render: function (rowdata, rowindex, value, column) {
                        console.log("rowdata:"+JSON.stringify(rowdata));
                            var h = '';
                            if(value&&value!="null"){
                                h+='<a href="javascript:commShowFlow(';
                                h+="'"+rowdata.pInstId+"',";
                                h+="'"+rowdata.compltFlowStsCd+"',";
                                h+="'"+rowdata.id+"'";
                                h+=')">'+value+'</a>'
                            }
                            return h;
                        },
                        enabledSort:true},
                    {
                        display: '操作',
                        isSort: false,
                        width: 200,
                        align:'left',
                        render: function (rowdata, rowindex, value){
                            console.log("rowdata:"+rowdata);
                            var h="";
                            if ("DTJ" == rowdata.compltStsCd ||  rowdata.compltFlowStsCd == CommonConstant.C_AUD_NO_HAPPEN_CODE || rowdata.compltFlowStsCd ==  CommonConstant.C_AUD_NO_PASS_CODE){
                                h+='<a class="sq-button-hasicon" href="javascript:modifyBtn(';
                                h+="'"+rowdata.id+"'";
                                h+=')"><i class="sqBtnIco_4"></i>修改</a>';
                            }
                            return h;
                        }
                    }
                ],
                pageSize:10,
                root:'rows',
                record:'total',
                hideLoadButton : true,
                width: '100%',
                height:'100%',
                heightDiff:-2,
                checkbox:true,
                allowUnSelectRow: true,
                alternatingRow: true,
                rownumbers:true,
                enabledEdit: true,
                isSingleCheck:true
            });
            grid = liger.get("grid");
            grid.setHeight(500);

        }

        //显示流程
        function commShowFlow(_pInsId, _compltStsCd, _businessKey){
            if(StringUtils.isEmpty(_pInsId)){
                UIUtils.alertWarning(CommonConstant.C_P_INSTANCEID_NOT_HERE);
                return;
            }

            var detailFlag = false;
            var _formUrl = "/insitution/prjInsRfeRecord/toPrjFillInfoPage.do?isFlow=0&fileNode=0&detailFlag=" + detailFlag + "&id="+_businessKey;
            var params = "?pInsId="+_pInsId+"&status="+_compltStsCd+"&businessKey="+_businessKey+"&formUrl="+_formUrl;
            Add_navTab('tab_cst_invoice_flow_'+_businessKey,'查看流程',"<%=path%>/flow/flow/toFlowShowPageFowBus.do"+params);
        }
        function modifyBtn(id){
            var callback = function(){
                grid.reload();
            }
            //查询参数
            var detailFlag = true;
            var params = "?isFlow=1&fileNode=1&detailFlag=" + detailFlag + "&id="+id;
            //var id = selectedRows[0].id;
            Add_navTab('tab_prj_ins_record_add'+id,'修改项目信息','<%=path%>/insitution/prjInsRfeRecord/toPrjFillInfoPage.do'+params,callback);
        }

        //格式化时间
        function renderDate(rowdata, index, value){
            var dateStr = "";
            if(null != value){
                var date = new Date(value);
                dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
            }
            return dateStr;
        }
    </script>
</head>
<body class="iframeBody">
    <div class="Wrapper">
        <div id="pageInTab" class="pageInTab">
            <div class="searchArea">
                <form id="searchBar">
                    <div class="fieldset1 clearFix">
                        <div class="fieldBox col_33">
                            <div class="label">合同号</div>
                            <div class="field">
                                <input name="lsCntNo" id="lsCntNo" type="text" class="ui-textbox" value="">
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">客户姓名</div>
                            <div class="field">
                                <input name="cstNm" id="cstNm" type="text" class="ui-textbox" value="">
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">资方放款时间</div>
                            <div class="field">
                                <input ligerui="width: 220" name="actPayTmBg" id="actPayTmBg" type="text" class="ui-datepicker" value="">
                                -
                                <input ligerui="width: 220" name="actPayTmEd" id="actPayTmEd" type="text" class="ui-datepicker" value="">
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">补件状态</div>
                            <div class="field">
                                <select name="compltStsCd"  id="compltStsCd" >
                                    <option value=" " selected="selected">--请选择--</option>
                                    <c:forEach items="${compltStsList}" var="item">
                                        <option value="${item.key}">${item.value}</option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">第三方机构</div>
                            <div class="field">
                                <select name="insCode"  id="insCode" >
                                    <option value=" " selected="selected">--请选择--</option>
                                    <c:forEach items="${friBaseList}" var="fri">
                                        <option value="${fri.insCode}">${fri.fundRasInsNm}</option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">补件节点</div>
                            <div class="field">
                                <select name="compltNodeCd"  id="compltNodeCd" >
                                    <option value=" " selected="selected">--请选择--</option>
                                    <c:forEach items="${compltNodeList}" var="item">
                                        <option value="${item.key}">${item.value}</option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">资方放款状态</div>
                            <div class="field">
                                <select name="payStsCd"  id="payStsCd" >
                                    <option value=" " selected="selected">--请选择--</option>
                                    <c:forEach items="${payStsCdList}" var="item">
                                        <option value="${item.key}">${item.value}</option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                        <div class="clearFix"></div>
                        <div class="btnsBox">
                            <span id="searchBtn"  class="sq-button sq-button-round">查询</span>
                            <span id="clearBtn" onclick="clearBtn();" class="sq-button sq-button-round">清空</span>
                        </div>
                    </div>
                </form>
                <div id="grid" class="sq-grid"></div>
            </div>
        </div>
    </div>
</body>
</html>